import { get, post } from "@/utils/service";

export function sendText(data: { room_id: number; message: string }) {
  if (!data.room_id) {
    data.room_id = 10002;
  }
  return post("message/sendText", data);
}

export function getHistory() {
  let room_id = Number(localStorage.getItem("room_id"));
  if (!room_id) {
    room_id = 10002;
  }
  return post("message/getHistory", { room_id });
}

export function getWebSocket(roomInfo: {
  room_id: number;
  room_password: string;
}) {
  if (!roomInfo.room_id) {
    roomInfo.room_id = 10002;
  }
  return post<{ tick: string }>("room/getWebSocketUrl", roomInfo);
}

export function addSong(info: { room_id: number; rid: number }) {
  return post("song/addSong", info);
}

export function getSongList(room_id: number) {
  return get("song/getSongList");
}
